﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using HA.Data;

using HA.ModFlow.Controls.UserControls;



using System.Collections.ObjectModel;


using System.Windows.Markup;
using System.Windows.Threading;
using System.Xml;


using HA.ModFlow.Controls.Converts;


 using System.Reflection;



namespace HA.ModFlow.Controls.Windows.MapData
{
    /// <summary>
    /// winAttributeV2.xaml 的交互逻辑
    /// </summary>
    public partial class winAttributeV2 : Window
    {
        public winAttributeV2(Coverage c,HA.ModFlow.Infrastructure.Units units)
        {
            InitializeComponent();

            this._coverage = c;

            this._units = units;


            this._attributeTable = new PCCoverageAtrributeTable(c);

           

            this.DataContext = this._attributeTable;

            this._selectedIds = new List<string>();


            ///默认显示全部的图形
            this.cbShow.SelectedIndex = 0;



            ucMultiInputMapData.mainWindow = this;

            MenuItem itemCopy = new MenuItem();
            itemCopy.Header = "复制";
            itemCopy.Command = ApplicationCommands.Copy;

            //MenuItem itemPaste2 = new MenuItem();
            //itemPaste2.Header = "粘贴";
            //itemPaste2.InputGestureText = "Ctrl+V";
            //itemPaste2.Click += new RoutedEventHandler(itemPaste2_Click);

            ContextMenu cm = new ContextMenu();
            cm.Items.Add(itemCopy);
            //cm.Items.Add(itemPaste2);          
            this.dtGrid.ContextMenu = cm;

        }

        Coverage _coverage;

        HA.ModFlow.Infrastructure.Units _units;

        PCCoverageAtrributeTable _attributeTable;

        public PCCoverageAtrributeTable AttributeTable
        {
            get { return _attributeTable; }
            set { _attributeTable = value; }
        }




        ListCollectionView _lcv;


        List<string> _selectedIds;


        /// <summary>
        /// 对外接口，表示是否仅仅显示选择的实体
        /// </summary>
        /// <param name="selectedIds"></param>
        public void SetSelectedId(IList<string> selectedIds)
        {
            this._selectedIds.Clear();

            this._selectedIds.AddRange(selectedIds);

            if (this._selectedIds.Count>0)
            {

                this.IsShowSelected = true;
                
            }
           



        }


        /// <summary>
        /// 指示是否只显示选择的物体
        /// </summary>
        public bool IsShowSelected
        {

            set
            {

                if (value == true)
                {
                    this.cbShow.SelectedIndex = 1;

                }
                else
                {
                    this.cbShow.SelectedIndex = 0;
                }

            }

        }








        #region 动态创建列

     

       

        //创建井
        protected void GenerateWellColumns()
        {
            //this.dtGrid.Columns.Clear();
            //DataGridTextColumn tc = new DataGridTextColumn();
            //Binding bin = new Binding("FeatureObject.Well.FlowRate");
            //tc.Binding = bin;
            //tc.Header = "井流速";
            //this.dtGrid.Columns.Add(tc);

            this.dtGrid.Columns.Clear();
            DataGridTemplateColumn column = new DataGridTemplateColumn();
            column.Header = "井流速[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^3/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
            DataTemplate dt = new DataTemplate();
            FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
            Binding binding = new Binding();
            binding.Path = new PropertyPath("FeatureObject.Well.MultiFlowRate");
            fef.SetBinding(ucMultiInputMapData .DataContextProperty, binding);
            dt.VisualTree = fef;
            column.CellTemplate = dt;
            this.dtGrid.Columns .Add(column);



            RefineColumns();
            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
            this.dtGrid.AutoGenerateColumns = false;
        }

        protected void NodeColumns()
        {         
            PCFeatureObject fo = lvFeatureObject.SelectedItem as PCFeatureObject;
            if (fo.FeatureObject is NodeFO)
            {
                NodeFO nf = (NodeFO)fo.FeatureObject;
                if (nf == null)
                {
                    return;
                }
                this.dtGrid.Columns.Clear();
                for (int i = 0; i < nf.RelationLines.Count; i++)
                {
                    switch (nf.RelationLines[i].SelectedSCType)
                    {
                        case MAPSCType.RIVER:
                            if (nf.RelationLines[i].IsStartNode(nf))
                            {
                               
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].River.MultiStartStage");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);

                                 column = new DataGridTemplateColumn();
                                 column.Header = "河床底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                 dt = new DataTemplate();
                                 fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                 binding = new Binding();
                                 binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].River.MultiStratElevation");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);


                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].River.StartStage");
                                //tc.Binding = bin;
                                //tc.Header = "RiverStartStage";
                                //this.dtGrid.Columns.Add(tc);

                                //tc = new DataGridTextColumn();
                                //bin = new Binding("FeatureObject.RelationLines[" + i + "].River.StartElevation");
                                //tc.Binding = bin;
                                //tc.Header = "RiverStartElevation";
                                //this.dtGrid.Columns.Add(tc);
                            }
                            if (nf.RelationLines[i].IsEndNode(nf))
                            {
                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].River.MultiEndStage");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);

                                 column = new DataGridTemplateColumn();
                                 column.Header = "河床底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                 dt = new DataTemplate();
                                 fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                 binding = new Binding();
                                 binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].River.MultiendElevation");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);

                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].River.EndStage");
                                //tc.Binding = bin;
                                //tc.Header = "RiverEndStage";
                                //this.dtGrid.Columns.Add(tc);

                                //tc = new DataGridTextColumn();
                                //bin = new Binding("FeatureObject.RelationLines[" + i + "].River.EndElevation");
                                //tc.Binding = bin;
                                //tc.Header = "RiverEndElevation";
                                //this.dtGrid.Columns.Add(tc);
                            }
                            break;
                        case MAPSCType.SPECIFIEDFLOW:


                            break;
                        case MAPSCType.SPECIFIEDHEAD:                          
                            if (nf.RelationLines[i].IsStartNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].SpecifiedHead.StageStart");
                                //tc.Binding = bin;
                                //tc.Header = "SpecifiedHeadStageStart";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].SpecifiedHead.MultiStageStart");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            if (nf.RelationLines[i].IsEndNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].SpecifiedHead.StageEnd");
                                //tc.Binding = bin;
                                //tc.Header = "SpecifiedHeadStageEnd";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].SpecifiedHead.MultiStageEnd");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            break;
                        case MAPSCType.GENERALHEAD:
                            if (nf.RelationLines[i].IsStartNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].GeneralHead.StartHead");
                                //tc.Binding = bin;
                                //tc.Header = "GeneralHeadStartHead";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].GeneralHead.MultiStartHead");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            if (nf.RelationLines[i].IsEndNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].GeneralHead.EndHead");
                                //tc.Binding = bin;
                                //tc.Header = "GeneralHeadEndHead";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].GeneralHead.MultiEndHead");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            break;
                        case MAPSCType.DRAIN:
                            if (nf.RelationLines[i].IsStartNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].Drain.StartElevation");
                                //tc.Binding = bin;
                                //tc.Header = "DrainStartElevation";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].Drain.MultiStartElevation");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            if (nf.RelationLines[i].IsEndNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].Drain.EndElevation");
                                //tc.Binding = bin;
                                //tc.Header = "DrainEndElevation";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].Drain.MultiEndElevation");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            break;

                        case MAPSCType.SEEPAGEFACE:
                            if (nf.RelationLines[i].IsStartNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].Seepage.ElevOffSetStart");
                                //tc.Binding = bin;
                                //tc.Header = "SeepageFaceElevOffSetStart";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "SeepageFaceElevOffSetStart";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].Seepage.MultiElevOffSetStart");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            if (nf.RelationLines[i].IsEndNode(nf))
                            {
                                //DataGridTextColumn tc = new DataGridTextColumn();
                                //Binding bin = new Binding("FeatureObject.RelationLines[" + i + "].Seepage.ElevOffSetEnd");
                                //tc.Binding = bin;
                                //tc.Header = "SeepageFaceElevOffSetEnd";
                                //this.dtGrid.Columns.Add(tc);

                                //this.dtGrid.Columns.Clear();
                                DataGridTemplateColumn column = new DataGridTemplateColumn();
                                column.Header = "SeepageFaceElevOffSetEnd";
                                DataTemplate dt = new DataTemplate();
                                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                                Binding binding = new Binding();
                                binding.Path = new PropertyPath("FeatureObject.RelationLines[" + i + "].Seepage.MultiElevOffSetEnd");
                                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                                dt.VisualTree = fef;
                                column.CellTemplate = dt;
                                this.dtGrid.Columns.Add(column);
                            }
                            break;
                    }
                }
            }
            
        }

        //创建River
        protected void GenerateRiverColumns(FeatureObjectType type)
        {
            //点和面用的是相同的属性------------------
            //this.dtGrid.Columns.Clear();
            //DataGridTextColumn tc = new DataGridTextColumn();
            //Binding bin = new Binding("FeatureObject.River.Stage");


            this.dtGrid.Columns.Clear();
            DataGridTemplateColumn column = new DataGridTemplateColumn();
            column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
            DataTemplate dt = new DataTemplate();
            FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
            Binding binding = new Binding();
          


            if (type == FeatureObjectType.POINT || type == FeatureObjectType.POLYGON)
            {
                //tc.Binding = bin;
                //tc.Header = "RiverStage";
                //this.dtGrid.Columns.Add(tc);

                binding.Path = new PropertyPath("FeatureObject.River.MultiStage");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.Elevation");
                //tc.Binding = bin;
                //tc.Header = "RiverElevation";
                //this.dtGrid.Columns.Add(tc);

                 column = new DataGridTemplateColumn();
                 column.Header = "河床底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                 dt = new DataTemplate();
                 fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                 binding = new Binding();
                 binding.Path = new PropertyPath("FeatureObject.River.MultiElevation");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.Conductance");
                //tc.Binding = bin;
                //tc.Header = "RiverConductance";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "河床导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.River.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

                if (type == FeatureObjectType.POINT)
                {
                    RefineColumns();
                }
            }
            //--------------------------
            //线---------------------              
            if (type == FeatureObjectType.LINE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.Conductance");
                //tc.Binding = bin;
                //tc.Header = "RiverConductance";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "河床导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.River.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

            }
            #region 端点 目前此方案不用
            if (type == FeatureObjectType.NODE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.StartStage");
                //tc.Binding = bin;
                //tc.Header = "RiverStartStage";
                //this.dtGrid.Columns.Add(tc);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.EndStage");
                //tc.Binding = bin;
                //tc.Header = "RiverEndStage";
                //this.dtGrid.Columns.Add(tc);

                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.StartElevation");
                //tc.Binding = bin;
                //tc.Header = "RiverStartElevation";
                //this.dtGrid.Columns.Add(tc);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.River.EndElevation");
                //tc.Binding = bin;
                //tc.Header = "RiverEndElevation";
                //this.dtGrid.Columns.Add(tc);
            #endregion
            }
            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
        }

        //创建SpecifiedFlow
        protected void GenerateSpecifiedFlowColumns(FeatureObjectType type)
        {
            this.dtGrid.Columns.Clear();
            DataGridTemplateColumn column = new DataGridTemplateColumn();
            DataTemplate dt;
            FrameworkElementFactory fef;
            Binding binding;

            if (type == FeatureObjectType.LINE || type == FeatureObjectType.POLYGON)
            {

                column.Header = "流速[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^3/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.SpecifiedFlow.MultiSpecifiedFlow");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);


            }
            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
        }

        //创建SpecifiedHead
        protected void GenerateSpecifiedHeadColumns(FeatureObjectType type)
        {

            //点和面用的是相同的属性------------------MultiStage

            if (type == FeatureObjectType.POINT || type == FeatureObjectType.POLYGON)
            {
                //this.dtGrid.Columns.Clear();
                //DataGridTextColumn tc = new DataGridTextColumn();
                //Binding bin = new Binding("FeatureObject.SpecifiedHead.Stage");
                //tc.Binding = bin;
                //tc.Header = "SpecifiedHeadStage";
                //this.dtGrid.Columns.Add(tc);


                this.dtGrid.Columns.Clear();
                DataGridTemplateColumn column = new DataGridTemplateColumn();
                column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                DataTemplate dt = new DataTemplate();
                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                Binding binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.SpecifiedHead.MultiStage");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

                if (type == FeatureObjectType.POINT)
                {
                    RefineColumns();
                }
            }
            if (type == FeatureObjectType.LINE)
            {
                //线--------------------经过分析GMS线类型似乎没有

                this.dtGrid.Columns.Clear();
            }
            #region 端点 目前此方案不用
            if (type == FeatureObjectType.NODE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.SpecifiedHead.StageStart");
                //tc.Binding = bin;
                //tc.Header = "SpecifiedHeadStageStart";
                //this.dtGrid.Columns.Add(tc);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.SpecifiedHead.StageEnd");
                //tc.Binding = bin;
                //tc.Header = "SpecifiedHeadStageEnd";
                //this.dtGrid.Columns.Add(tc);
            }
            #endregion

            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {             
                this.LayerRangeColumns();
            }
        }
        //创建GeneralHead
        protected void GenerateGeneralHeadColumns(FeatureObjectType type)
        {
            //点和面用的是相同的属性------------------
            //this.dtGrid.Columns.Clear(); 
            //DataGridTextColumn tc = new DataGridTextColumn();
            //Binding bin = new Binding("FeatureObject.GeneralHead.HeadStage");


            this.dtGrid.Columns.Clear();
            DataGridTemplateColumn column = new DataGridTemplateColumn();
            column.Header = "水头-应力期[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
            DataTemplate dt = new DataTemplate();
            FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
            Binding binding = new Binding();
            if (type == FeatureObjectType.POINT || type == FeatureObjectType.POLYGON)
            {
                //tc.Binding = bin;
                //tc.Header = "GeneralHeadHeadStage";
                //this.dtGrid.Columns.Add(tc);


                binding.Path = new PropertyPath("FeatureObject.GeneralHead.MultiHeadStage");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.GeneralHead.Conductance");
                //tc.Binding = bin;
                //tc.Header = "GeneralHeadConductance";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "界面渗透系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                dt = new DataTemplate();
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.GeneralHead.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);
              
                if (type == FeatureObjectType.POINT)
                {
                    RefineColumns();
                }
            }
            //线-------------------------------
            if (type == FeatureObjectType.LINE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.GeneralHead.Conductance");
                //tc.Binding = bin;
                //tc.Header = "GeneralHeadConductance";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "界面渗透系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.GeneralHead.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

            }
            #region 端点 目前此方案不用
            if (type == FeatureObjectType.NODE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.GeneralHead.StartHead");
                //tc.Binding = bin;
                //tc.Header = "GeneralHeadStartHead";
                //this.dtGrid.Columns.Add(tc);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.GeneralHead.EndHead");
                //tc.Binding = bin;
                //tc.Header = "GeneralHeadEndHead";
                //this.dtGrid.Columns.Add(tc);
            }
            #endregion
            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
        }

        //创建Drain
        protected void GenerateDrainColumns(FeatureObjectType type)
        {
            //this.dtGrid.Columns.Clear();
            ////点和面用的是相同的属性------------------
            //DataGridTextColumn tc = new DataGridTextColumn();
            //Binding bin = new Binding("FeatureObject.Drain.FirstConductance");


            this.dtGrid.Columns.Clear();
            DataGridTemplateColumn column = new DataGridTemplateColumn();
            column.Header = "界面导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
            DataTemplate dt = new DataTemplate();
            FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
            Binding binding = new Binding();
            if (type == FeatureObjectType.POINT || type == FeatureObjectType.POLYGON)
            {
                //tc.Binding = bin;
                //tc.Header = "DrainFirstConductance";
                //this.dtGrid.Columns.Add(tc);

                binding.Path = new PropertyPath("FeatureObject.Drain.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Drain.Elevation");
                //tc.Binding = bin;
                //tc.Header = "DrainElevation";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "渠底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";              
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.Drain.MultiElevation");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

                if (type == FeatureObjectType.POINT)
                {
                    RefineColumns();
                }
            }
            //线------------------------------------
            if (type == FeatureObjectType.LINE)
            {  
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Drain.FirstConductance");
                //tc.Binding = bin;
                //tc.Header = "DrainFirstConductance";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "界面导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.Drain.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);
            }
            #region 端点 目前此方案不用
            if (type == FeatureObjectType.NODE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Drain.StartElevation");
                //tc.Binding = bin;
                //tc.Header = "DrainStartElevation";
                //this.dtGrid.Columns.Add(tc);

                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Drain.EndElevation");
                //tc.Binding = bin;
                //tc.Header = "DrainEndElevation";
                //this.dtGrid.Columns.Add(tc);
            }
            #endregion
            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
        }

        //创建SeepageFace
        protected void GenerateSeepageFaceColumns(FeatureObjectType type)
        {
            //this.dtGrid.Columns.Clear(); 
            ////点和面用的是相同的属性------------------
            //DataGridTextColumn tc = new DataGridTextColumn();
            //Binding bin = new Binding("FeatureObject.Seepage.Conductance");

            this.dtGrid.Columns.Clear();
            DataGridTemplateColumn column = new DataGridTemplateColumn();
            column.Header = "导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
            DataTemplate dt = new DataTemplate();
            FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
            Binding binding = new Binding();


            if (type == FeatureObjectType.POINT || type == FeatureObjectType.POLYGON)
            {
                //tc.Binding = bin;
                //tc.Header = "SeepageFaceConductance";
                //this.dtGrid.Columns.Add(tc);

                binding.Path = new PropertyPath("FeatureObject.Seepage.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);


            
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Seepage.ElevOffSet");
                //tc.Binding = bin;
                //tc.Header = "SeepageFaceElevOffSet";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "SeepageFaceElevOffSet";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.Seepage.MultiElevOffSet");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);
            
                if (type == FeatureObjectType.POINT)
                {
                    RefineColumns();
                }
            }
            //线--------------------------------
            if (type == FeatureObjectType.LINE)
            {               
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Seepage.Conductance");
                //tc.Binding = bin;
                //tc.Header = "SeepageFaceConductance";
                //this.dtGrid.Columns.Add(tc);

                column = new DataGridTemplateColumn();
                column.Header = "导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                dt = new DataTemplate();
                fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.Seepage.MultiConductance");
                fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

            }
            #region 端点 目前此方案不用
            if (type == FeatureObjectType.NODE)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Seepage.ElevOffSetStart");
                //tc.Binding = bin;
                //tc.Header = "SeepageFaceElevOffSetStart";
                //this.dtGrid.Columns.Add(tc);


                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.Seepage.ElevOffSetEnd");
                //tc.Binding = bin;
                //tc.Header = "SeepageFaceElevOffSetEnd";
                //this.dtGrid.Columns.Add(tc);
            }
            #endregion

            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
        }

        //创建Barrier
        protected void GenerateBarrierColumns()
        {
            this.dtGrid.Columns.Clear();
            DataGridTextColumn tc = new DataGridTextColumn();
            Binding bin = new Binding("FeatureObject.Barrier.HydChar");
            tc.Header = "水力特性";
            tc.Binding = bin;
            this.dtGrid.Columns.Add(tc);

            //this.dtGrid.Columns.Clear();
            //DataGridTemplateColumn column = new DataGridTemplateColumn();
            //column.Header = "Hyd.char";
            //DataTemplate dt = new DataTemplate();
            //FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
            //Binding binding = new Binding();

            //binding.Path = new PropertyPath("FeatureObject.Barrier.HydChar");
            //fef.SetBinding(ucMultiInputMapData.DataContextProperty, binding);
            //dt.VisualTree = fef;
            //column.CellTemplate = dt;
            //this.dtGrid.Columns.Add(column);

            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }
        }

        //创建ArealProperity
        protected void ArealProperityColumns()
        {
            this.dtGrid.Columns.Clear();
            //DataGridTextColumn tc = new DataGridTextColumn();
            //Binding bin = new Binding("FeatureObject.ArealPropertyData.RechargeRate");
              
            if (_coverage.Setup.ArealTypes[MAPArealType.RECHARGERATE] == true)
            {
                //tc.Binding = bin;
                //tc.Header = "补给速率(" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + ")";
                //this.dtGrid.Columns.Add(tc);



                DataGridTemplateColumn column = new DataGridTemplateColumn();
                column.Header = "补给速率[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                DataTemplate dt = new DataTemplate();
                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                Binding binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.ArealPropertyData.RechargeRate.DateDatas");
                fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

            }

            DataGridTextColumn tc = new DataGridTextColumn();
            Binding bin = new Binding();
            if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
            {
                this.LayerRangeColumns();
            }

            if (_coverage.Setup.ArealTypes[MAPArealType.HORIZONTALK] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Hk");
                tc.Binding = bin;
                tc.Header = "水平渗透系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.VERTICLEK] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Vk");
                tc.Binding = bin;
                tc.Header = "垂向渗透系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.HORIZONTALANIS] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Hani");
                tc.Binding = bin;
                tc.Header = "水平异质性";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.VERTICLEANIS] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Vani");
                tc.Binding = bin;
                tc.Header = "垂向异质性";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.SPECIFICSTORAGE] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.SpecStorage");
                tc.Binding = bin;
                tc.Header = "贮水系数[1/" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.SPECIFICYIELD] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.SpecYield");
                tc.Binding = bin;
                tc.Header = "给水度";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.TOPELVE] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.GridTopElev");
                tc.Binding = bin;
                tc.Header = "顶板海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.BOTELVE] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.GridBotElev");
                tc.Binding = bin;
                tc.Header = "底部海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                this.dtGrid.Columns.Add(tc);

            }
            if (_coverage.Setup.ArealTypes[MAPArealType.WETDRYFALG] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.WetdryFlag");
                tc.Binding = bin;
                tc.Header = "干湿转换标志";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.MAXETRATE] == true)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.ArealPropertyData.MaxETRate");
                //tc.Binding = bin;
                //tc.Header = "最大蒸散速率[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                //this.dtGrid.Columns.Add(tc);

                DataGridTemplateColumn column = new DataGridTemplateColumn();
                column.Header = "最大蒸散速率[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                DataTemplate dt = new DataTemplate();
                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                Binding binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.ArealPropertyData.MaxETRateV2.DateDatas");
                fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.ETELEV] == true)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.ArealPropertyData.EtRate");
                //tc.Binding = bin;
                //tc.Header = "蒸散界面海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                //this.dtGrid.Columns.Add(tc);


                DataGridTemplateColumn column = new DataGridTemplateColumn();
                column.Header = "蒸散界面海拔[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                DataTemplate dt = new DataTemplate();
                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                Binding binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.ArealPropertyData.EtRateV2.DateDatas");
                fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);
            }

            if (_coverage.Setup.ArealTypes[MAPArealType.ETEXTINCTIONDEPTH] == true)
            {
                //tc = new DataGridTextColumn();
                //bin = new Binding("FeatureObject.ArealPropertyData.EtExtDepth");
                //tc.Binding = bin;
                //tc.Header = "蒸散终止深度[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                //this.dtGrid.Columns.Add(tc);


                DataGridTemplateColumn column = new DataGridTemplateColumn();
                column.Header = "蒸散终止深度[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                DataTemplate dt = new DataTemplate();
                FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                Binding binding = new Binding();
                binding.Path = new PropertyPath("FeatureObject.ArealPropertyData.EtExtDepthV2.DateDatas");
                fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                dt.VisualTree = fef;
                column.CellTemplate = dt;
                this.dtGrid.Columns.Add(column);
            }

            if (_coverage.Setup.ArealTypes[MAPArealType.POROSITY] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Porosity");
                tc.Binding = bin;
                tc.Header = "有效孔隙度";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.TRANSMISSITY] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Transmissity");
                tc.Binding = bin;
                tc.Header = "导水系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.LEAKANCE] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Leakance");
                tc.Binding = bin;
                tc.Header = "垂向水力传导率";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.PrimaryStorage] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.PrimaryStorage");
                tc.Binding = bin;
                tc.Header = "第一类贮水系数";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.SecondaryStorage] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.SecondStorage");
                tc.Binding = bin;
                tc.Header = "第二类贮水系数";
                this.dtGrid.Columns.Add(tc);

            }
            if (_coverage.Setup.ArealTypes[MAPArealType.BULKDENSITY] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Bulkdensity");
                tc.Binding = bin;
                tc.Header = "含水层介质容重[" + Domain.DomainLayer.UnitConverter.GetConcentration(_units) + "]";
                this.dtGrid.Columns.Add(tc);

            }
            if (_coverage.Setup.ArealTypes[MAPArealType.IMMOBILEPOROSITY] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Immobileporosity");
                tc.Binding = bin;
                tc.Header = "不流动区域的孔隙度";
                this.dtGrid.Columns.Add(tc);

            }

            if (_coverage.Setup.ArealTypes[MAPArealType.LONGDISPERSITY] == true)
            {
                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.ArealPropertyData.Longdispersity");
                tc.Binding = bin;
                tc.Header = "有效分子扩散系数[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "^2/" + Domain.DomainLayer.UnitConverter.GetTime(_units.Time) + "]";
                this.dtGrid.Columns.Add(tc);
            }        
        }
        /// <summary>
        /// 相染污物相关的源汇
        /// </summary>
        private void SpecesRelevant()
        {
            if (_coverage.Setup.ArealTypes[MAPArealType.STARTINGCONCENTRATION] == true)
            {
                PCFeatureObject fo = lvFeatureObject.SelectedItem as PCFeatureObject;
                if (fo.FeatureObject is PolygonFO)
                {
                    PolygonFO starCon = (PolygonFO)fo.FeatureObject;
                    if (starCon == null)
                    {
                        return;
                    }
                    else
                    {
                        for (int i = 0; i < starCon.ArealPropertyData.Startingconcentration.SpecConc.Count; i++)
                        {
                            DataGridTextColumn tc = new DataGridTextColumn();
                            Binding bin = new Binding("FeatureObject.ArealPropertyData.Startingconcentration.SpecConc[" + i.ToString() + "]");
                            tc.Binding = bin;
                            tc.Header = "初始浓度_" + starCon.ArealPropertyData.Startingconcentration.SpecNames[i] + "[" + Domain.DomainLayer.UnitConverter.GetConcentration(_units) + "]";
                            this.dtGrid.Columns.Add(tc);
                        }
                    }
                }
            }

            if (_coverage.Setup.ArealTypes[MAPArealType.RECHARGECONC] == true)
            {
                PCFeatureObject fo = lvFeatureObject.SelectedItem as PCFeatureObject;
                if (fo.FeatureObject is PolygonFO)
                {
                    PolygonFO starCon = (PolygonFO)fo.FeatureObject;
                    if (starCon == null)
                    {
                        return;
                    }
                    else
                    {
                        for (int i = 0; i < starCon.ArealPropertyData.RechargeConc.SpecConc.Count; i++)
                        {
                            DataGridTemplateColumn column = new DataGridTemplateColumn();
                            column.Header = "补给浓度_" + starCon.ArealPropertyData.RechargeConc.SpecConc[i].Name;
                            DataTemplate dt = new DataTemplate();
                            FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                            Binding binding = new Binding();
                            binding.Path = new PropertyPath("FeatureObject.ArealPropertyData.RechargeConc.SpecConc[" + i + "].DateDatas");
                            fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                            dt.VisualTree = fef;
                            column.CellTemplate = dt;
                            this.dtGrid.Columns.Add(column);
                        }
                    }
                }
            }
        }

        //创建LayerRange
        protected void LayerRangeColumns()
        {
            //this.dtGrid.Columns.Clear();
            DataGridTextColumn tc = new DataGridTextColumn();
            Binding bin = new Binding("FeatureObject.LayerRange.FromLayer");
            tc.Binding = bin;
            tc.Header = "起始层";
            this.dtGrid.Columns.Add(tc);
           

            tc = new DataGridTextColumn();
            bin = new Binding("FeatureObject.LayerRange.ToLayer");
            tc.Binding = bin;
            tc.Header = "结束层";
            this.dtGrid.Columns.Add(tc);
           
        }

        //创建Refine
        protected void RefineColumns()
        {
            if (this._coverage.Setup.ScTypes[MAPSCType.REFINEPOINTS] == true)
            {
                DataGridCheckBoxColumn chk = new DataGridCheckBoxColumn();
                Binding b = new Binding("FeatureObject.RefinePoint.Enabled");
                chk.Binding = b;
                chk.Header = "参照点";
                this.dtGrid.Columns.Add(chk);
               

                DataGridTextColumn tc = new DataGridTextColumn();
                Binding bin = new Binding("FeatureObject.RefinePoint.BaseSize");
                tc.Binding = bin;
                tc.Header = "基础尺寸[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                this.dtGrid.Columns.Add(tc);
              

                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.RefinePoint.Bias");
                tc.Binding = bin;
                tc.Header = "偏差";
                this.dtGrid.Columns.Add(tc);
               


                tc = new DataGridTextColumn();
                bin = new Binding("FeatureObject.RefinePoint.MaxSize");
                tc.Binding = bin;
                tc.Header = "最大尺寸[" + Domain.DomainLayer.UnitConverter.GetLength(_units.Length) + "]";
                this.dtGrid.Columns.Add(tc);
            
            }
      
        }

        protected void Massloading()
        {
            this.dtGrid.Columns.Clear();
            if (this._coverage.Setup.ScTypes[MAPSCType.MASSLOADING] == true)
            {
                if (this._attributeTable.Features.Count > 0)
                {
                    this.dtGrid.Columns.Clear();
                    for (int i = 0; i < this._attributeTable.Features[0].FeatureObject.MassLoading.SpecConc.Count; i++)
                    {
                        DataGridTemplateColumn column = new DataGridTemplateColumn();
                        column.Header = "质量负载率_" + this._attributeTable.Features[0].FeatureObject.MassLoading.SpecConc[i].Name;
                        DataTemplate dt = new DataTemplate();
                        FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                        Binding binding = new Binding();
                        binding.Path = new PropertyPath("FeatureObject.MassLoading.SpecConc[" + i + "].DateDatas");
                        fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                        dt.VisualTree = fef;
                        column.CellTemplate = dt;
                        this.dtGrid.Columns.Add(column);
                    }
                }
            }
        }

        protected void SpecConc()
        {
            this.dtGrid.Columns.Clear();
            if (this._coverage.Setup.ScTypes[MAPSCType.SPECIFIEDCONC] == true)
            {
                if (this._attributeTable.Features.Count > 0)
                {
                    this.dtGrid.Columns.Clear();
                    for (int i = 0; i < this._attributeTable.Features[0].FeatureObject.SpecConc.SpecConc.Count; i++)
                    {
                        DataGridTemplateColumn column = new DataGridTemplateColumn();
                        column.Header = "质量负载浓度_" + this._attributeTable.Features[0].FeatureObject.SpecConc.SpecConc[i].Name;
                        DataTemplate dt = new DataTemplate();
                        FrameworkElementFactory fef = new FrameworkElementFactory(typeof(HA.ModFlow.Controls.UserControls.ucMultiInputMapData));
                        Binding binding = new Binding();
                        binding.Path = new PropertyPath("FeatureObject.SpecConc.SpecConc[" + i + "].DateDatas");
                        fef.SetBinding(HA.ModFlow.Controls.UserControls.ucMultiInputMapData.DataContextProperty, binding);
                        dt.VisualTree = fef;
                        column.CellTemplate = dt;
                        this.dtGrid.Columns.Add(column);
                    }
                }
            }
        }

       


       


        //创建Observation
        protected void ObservationColumns()
        {

        }



        #endregion


        private bool IsShowItem(object item)
        {


            PCFeatureObject fo = (PCFeatureObject)item;


            //需要分别考虑多种情况,包括选择类型，实体类型，bc类型等

            if (this._attributeTable.CurrentFOType == FeatureObjectType.POINT)
            {
                bool b = fo.FeatureObject is PointFO;

                if (!b)
                {
                    return false;

                }


            }

            if (this._attributeTable.CurrentFOType == FeatureObjectType.NODE)
            {
                bool b = fo.FeatureObject is NodeFO;

                if (!b)
                {
                    return false;

                }


            }

            if (this._attributeTable.CurrentFOType == FeatureObjectType.LINE)
            {
                bool b = fo.FeatureObject is LineFO;

                if (!b)
                {
                    return false;

                }


            }

            if (this._attributeTable.CurrentFOType == FeatureObjectType.POLYGON)
            {
                bool b = fo.FeatureObject is PolygonFO;

                if (!b)
                {
                    return false;

                }


            }



            ///是否考虑选择


            if (this.cbShow.SelectedIndex == 0)
            {
                return true;

            }

            ///只显示选择了的实体
            if (this.cbShow.SelectedIndex == 1)
            {




                if (this._selectedIds.Contains(fo.FeatureObject.Id))
                {
                    return true;

                }
                else
                {
                    return false;
                }


            }



            return true;








        }



        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            //_lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(dtGrid.ItemsSource);
            _lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(this.lvFeatureObject.ItemsSource);

            _lcv.Filter = new Predicate<object>(IsShowItem);


            if (this._attributeTable.Features.Count > 0)
            {
                this.lvFeatureObject.SelectedIndex = 0;

            }
            else
            {
               
            }


            //当全部选中时,默认

            if (this.cbShow.SelectedIndex!=0)
            {

                if (this._selectedIds.Count>0)
                {
                    string id = this._selectedIds[0];

                   FeatureObject fo= this._coverage.GetFeatueObject(id);

                   if (fo is PointFO)
                   {
                       this._attributeTable.CurrentFOType = FeatureObjectType.POINT;

                   }

                   if (fo is LineFO)
                   {
                       this._attributeTable.CurrentFOType = FeatureObjectType.LINE;

                   }

                   if (fo is PolygonFO)
                   {
                       this._attributeTable.CurrentFOType = FeatureObjectType.POLYGON;

                   }

                   if (fo is NodeFO)
                   {
                       this._attributeTable.CurrentFOType = FeatureObjectType.NODE;

                   }
                    
                }

             



                
            }


        }



        private void cbShow_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this._lcv != null)
            {

                this._lcv.Refresh();

            }


        }

        private void cbFeatureType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this._lcv != null)
            {
                this._lcv.Refresh();
                this.ShowRightColumn();
            }
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            this._attributeTable.Confirm();
            this.DialogResult = true;
            this.Close();
        }

        private void btnCancal_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }


        /// <summary>
        /// 当当前的选择类型发生变化的时候
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.ShowRightColumn();

        }

        protected void MapscType(PCFeatureObject fo,FeatureObjectType type)
        {
            if (fo.FeatureObject.SelectedSCType == MAPSCType.NONE)
            {
                if (type == FeatureObjectType.NODE)
                {
                    this.dtGrid.Columns.Clear();
                    NodeColumns();
                }
                else
                {
                    this.dtGrid.Columns.Clear();
                }
           
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.BARRIER)
            {
                this.GenerateBarrierColumns();
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.DRAIN)
            {
                this.GenerateDrainColumns(type);
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.GENERALHEAD)
            {
                this.GenerateGeneralHeadColumns(type);
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.LAKE)
            {
                this.dtGrid.Columns.Clear();
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.LAYERRANGE)
            {
                this.LayerRangeColumns();
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.OBSERVEDFLOW)
            {
                this.dtGrid.Columns.Clear();
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.REFINEPOINTS)
            {
                this.RefineColumns();
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.RIVER)
            {
                this.GenerateRiverColumns(type);
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.SEEPAGEFACE)
            {
                this.GenerateSeepageFaceColumns(type);
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.SPECIFIEDFLOW)
            {
                this.GenerateSpecifiedFlowColumns(type);
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.SPECIFIEDHEAD)
            {
                this.GenerateSpecifiedHeadColumns(type);
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.TANSOBSERVEDFLOW)
            {
                this.dtGrid.Columns.Clear();
            }
            //新加MT3D部分
            if (fo.FeatureObject.SelectedSCType == MAPSCType.SPECIFIEDCONC)
            {
                SpecConc();
            }
            if (fo.FeatureObject.SelectedSCType == MAPSCType.MASSLOADING)
            {
                Massloading();
            }
            //---------------------

            if (type == FeatureObjectType.POINT)
            {
                if (fo.FeatureObject.SelectedSCType == MAPSCType.WELL)
                {
                    this.GenerateWellColumns();
                }
            }



            if (type == FeatureObjectType.POLYGON)
            {
                if (fo.FeatureObject.SelectedSCType == MAPSCType.NONE)
                {
                    this.ArealProperityColumns();
                }              
            }
            SpecesRelevant();
        }

        protected void ShowRightColumn()
        {
            PCFeatureObject fo = lvFeatureObject.SelectedItem as PCFeatureObject;   
            if (fo != null)
            {
                MapscType(fo, this._attributeTable.CurrentFOType);  
                //if (this._attributeTable.CurrentFOType == FeatureObjectType.POINT)
                //{
                //    MapscType(fo, FeatureObjectType.POINT);                  
                //}
                //if (this._attributeTable.CurrentFOType == FeatureObjectType.LINE)
                //{
                //    MapscType(fo, FeatureObjectType.LINE);                  
                //}
                //if (this._attributeTable.CurrentFOType == FeatureObjectType.POLYGON)
                //{                    
                //    MapscType(fo, FeatureObjectType.POLYGON);  
                //}
                //if (this._attributeTable.CurrentFOType == FeatureObjectType.NODE)
                //{
                //    MapscType(fo, FeatureObjectType.NODE);
                //}
                if (this._attributeTable.CurrentFOType == FeatureObjectType.POINT && fo.FeatureObject.SelectedSCType == MAPSCType.NONE)
                {
                    RefineColumns();
                    if (_coverage.Setup.ScTypes[MAPSCType.LAYERRANGE] == true)
                    {
                        this.LayerRangeColumns();
                    }
                  
                }
            }
 
        }

        private void dtGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {

            this.ShowRightColumn();



        }




        //protected void ConvertToVisibility()

    }

    public class ConvertToVisibilityPointFO : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FeatureObject obj = (FeatureObject)value;
            if (obj is PointFO)
            {
                return Visibility.Visible;
            }
            else
            {
                return Visibility.Hidden;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    public class ConvertToVisibilityLineFO : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FeatureObject obj = (FeatureObject)value;
            if (obj is LineFO)
            {
                return Visibility.Visible;
            }
            else
            {
                return Visibility.Hidden;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    public class ConvertToVisibilityPolygonFO : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FeatureObject obj = (FeatureObject)value;
            if (obj is PolygonFO)
            {
                return Visibility.Visible;
            }
            else
            {
                return Visibility.Hidden;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class converttobool : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            HA.Data.ConcType type = (HA.Data.ConcType)value;
            if (type == HA.Data.ConcType.Constant)
            {
                return System.Windows.Visibility.Hidden;
            }
            else
            {
                return System.Windows.Visibility.Visible;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class MAPSCTypeToCNConverter : IValueConverter
    {

        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if ((value as List<MAPSCType>) != null)
            {
                List<MAPSCType> types = (List<MAPSCType>)value;
                List<string> cns = new List<string>();
                foreach (var item in types)
                {
                    switch (item)
                    {
                        case MAPSCType.LAYERRANGE:
                            cns.Add("层范围");
                            continue;
                        case MAPSCType.WELL:
                            cns.Add("井");
                            continue;
                        case MAPSCType.REFINEPOINTS:
                            cns.Add("参照点");
                            continue;
                        case MAPSCType.SPECIFIEDHEAD:
                            cns.Add("定水头");
                            continue;
                        case MAPSCType.SPECIFIEDFLOW:
                            cns.Add("给定流量");
                            continue;
                        case MAPSCType.GENERALHEAD:
                            cns.Add("通用水头");
                            continue;
                        case MAPSCType.DRAIN:
                            cns.Add("排水渠");
                            continue;
                        case MAPSCType.RIVER:
                            cns.Add("河流");
                            continue;
                        case MAPSCType.LAKE:
                            cns.Add("湖泊");
                            continue;
                        case MAPSCType.BARRIER:
                            cns.Add("屏障");
                            continue;
                        case MAPSCType.OBSERVEDFLOW:
                            cns.Add("OBSERVEDFLOW");
                            continue;
                        case MAPSCType.TANSOBSERVEDFLOW:
                            cns.Add("TANSOBSERVEDFLOW");
                            continue;
                        case MAPSCType.SEEPAGEFACE:
                            cns.Add("SEEPAGEFACE");
                            continue;
                        case MAPSCType.NONE:
                            cns.Add("无量纲");
                            continue;
                        case MAPSCType.SPECIFIEDCONC:
                            cns.Add("给定浓度");
                            continue;
                        case MAPSCType.MASSLOADING:
                            cns.Add("质量负载");
                            continue;
                        default:
                            throw new Exception();

                    }
                }
                return cns;
            }
            else
            {
                MAPSCType type = (MAPSCType)value;
                switch (type)
                {
                    case MAPSCType.LAYERRANGE:
                        return "层范围";
                    case MAPSCType.WELL:
                        return "井";
                    case MAPSCType.REFINEPOINTS:
                        return "参照点";
                    case MAPSCType.SPECIFIEDHEAD:
                        return "定水头";
                    case MAPSCType.SPECIFIEDFLOW:
                        return "给定流量";
                    case MAPSCType.GENERALHEAD:
                        return "通用水头";
                    case MAPSCType.DRAIN:
                        return "排水渠";
                    case MAPSCType.RIVER:
                        return "河流";
                    case MAPSCType.LAKE:
                        return "湖泊";
                    case MAPSCType.BARRIER:
                        return "屏障";
                    case MAPSCType.OBSERVEDFLOW:
                        return "OBSERVEDFLOW";
                    case MAPSCType.TANSOBSERVEDFLOW:
                        return "TANSOBSERVEDFLOW";
                    case MAPSCType.SEEPAGEFACE:
                        return "SEEPAGEFACE";
                    case MAPSCType.NONE:
                        return "无量纲";
                    case MAPSCType.SPECIFIEDCONC:
                        return "给定浓度";
                    case MAPSCType.MASSLOADING:
                        return "质量负载";
                    default:
                        throw new Exception();

                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return null;
            if ((value as List<string>) != null)
            {
                List<string> types = (List<string>)value;
                List<MAPSCType> cns = new List<MAPSCType>();
                foreach (var item in types)
                {
                    switch (item)
                    {
                        case "层范围":
                            cns.Add(MAPSCType.LAYERRANGE);
                            continue;
                        case "井":
                            cns.Add(MAPSCType.WELL);
                            continue;
                        case "参照点":
                            cns.Add(MAPSCType.REFINEPOINTS);
                            continue;
                        case "定水头":
                            cns.Add(MAPSCType.SPECIFIEDHEAD);
                            continue;
                        case "给定流量":
                            cns.Add(MAPSCType.SPECIFIEDFLOW);
                            continue;
                        case "通用水头":
                            cns.Add(MAPSCType.GENERALHEAD);
                            continue;
                        case "排水渠":
                            cns.Add(MAPSCType.DRAIN);
                            continue;
                        case "河流":
                            cns.Add(MAPSCType.RIVER);
                            continue;
                        case "湖泊":
                            cns.Add(MAPSCType.LAKE);
                            continue;
                        case "屏障":
                            cns.Add(MAPSCType.BARRIER);
                            continue;
                        case "OBSERVEDFLOW":
                            cns.Add(MAPSCType.OBSERVEDFLOW);
                            continue;
                        case "TANSOBSERVEDFLOW":
                            cns.Add(MAPSCType.TANSOBSERVEDFLOW);
                            continue;
                        case "SEEPAGEFACE":
                            cns.Add(MAPSCType.SEEPAGEFACE);
                            continue;
                        case "无量纲":
                            cns.Add(MAPSCType.NONE);
                            continue;
                        case "给定浓度":
                            cns.Add(MAPSCType.SPECIFIEDCONC);
                            continue;
                        case "质量负载":
                            cns.Add(MAPSCType.MASSLOADING);
                            continue;
                        default:
                            throw new Exception();
                    }
                }
                return cns;
            }
            else
            {
                string type = (string)value;
                switch (type)
                {
                    case "层范围":
                        return MAPSCType.LAYERRANGE;
                    case "井":
                        return MAPSCType.WELL;
                    case "参照点":
                        return MAPSCType.REFINEPOINTS;
                    case "定水头":
                        return MAPSCType.SPECIFIEDHEAD;
                    case "给定流量":
                        return MAPSCType.SPECIFIEDFLOW;
                    case "通用水头":
                        return MAPSCType.GENERALHEAD;
                    case "排水渠":
                        return MAPSCType.DRAIN;
                    case "河流":
                        return MAPSCType.RIVER;
                    case "湖泊":
                        return MAPSCType.LAKE;
                    case "屏障":
                        return MAPSCType.BARRIER;
                    case "OBSERVEDFLOW":
                        return MAPSCType.OBSERVEDFLOW;
                    case "TANSOBSERVEDFLOW":
                        return MAPSCType.TANSOBSERVEDFLOW;
                    case "SEEPAGEFACE":
                        return MAPSCType.SEEPAGEFACE;
                    case "无量纲":
                        return MAPSCType.NONE;
                    case "给定浓度":
                        return MAPSCType.SPECIFIEDCONC;
                    case "质量负载":
                        return MAPSCType.MASSLOADING;
                    default:
                        throw new Exception();
                }
            }
        }

        #endregion
    }

    public class FOTypeToCNConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if ((value as List<FeatureObjectType>) != null)
            {
                List<FeatureObjectType> types = (List<FeatureObjectType>)value;
                List<string> cns = new List<string>();
                foreach (var item in types)
                {
                    switch (item)
                    {
                        case FeatureObjectType.POINT:
                            cns.Add("点");
                            continue;
                        case FeatureObjectType.LINE:
                            cns.Add("线");
                            continue;
                        case FeatureObjectType.POLYGON:
                            cns.Add("面");
                            continue;
                        case FeatureObjectType.NODE:
                            cns.Add("端点");
                            continue;
                        case FeatureObjectType.LINEGROUP:
                            cns.Add("线组");
                            continue;
                        default:
                            throw new Exception();
                    }
                }
                return cns;
            }
            else
            {
                FeatureObjectType type = (FeatureObjectType)value;
                switch (type)
                {
                    case FeatureObjectType.POINT:
                        return "点";
                    case FeatureObjectType.LINE:
                        return "线";
                    case FeatureObjectType.POLYGON:
                        return "面";
                    case FeatureObjectType.NODE:
                        return "端点";
                    case FeatureObjectType.LINEGROUP:
                        return "线组";
                    default:
                        throw new Exception();
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if ((value as List<string>) != null)
            {
                List<string> types = (List<string>)value;
                List<FeatureObjectType> cns = new List<FeatureObjectType>();
                foreach (var item in types)
                {
                    switch (item)
                    {
                        case "点":
                            cns.Add(FeatureObjectType.POINT);
                            continue;
                        case "线":
                            cns.Add(FeatureObjectType.LINE);
                            continue;
                        case "面":
                            cns.Add(FeatureObjectType.POLYGON);
                            continue;
                        case "端点":
                            cns.Add(FeatureObjectType.NODE);
                            continue;
                        case "线组":
                            cns.Add(FeatureObjectType.LINEGROUP);
                            continue;
                        default:
                            throw new Exception();
                    }
                }
                return cns;
            }
            else
            {
                string type = (string)value;
                switch (type)
                {
                    case "点":
                        return FeatureObjectType.POINT;
                    case "线":
                        return FeatureObjectType.LINE;
                    case "面":
                        return FeatureObjectType.POLYGON;
                    case "端点":
                        return FeatureObjectType.NODE;
                    case "线组":
                        return FeatureObjectType.LINEGROUP;
                    default:
                        throw new Exception();
                }
            }
        }
    }
}
